<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台管理</title>
<link rel="stylesheet" href="<?php echo base_url('publics/admin');?>/style/styles.css" />
<script type="text/javascript" src="<?php echo base_url('publics')?>/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo base_url('publics')?>/js/na_check.js"></script>
</head>

<body>
<div id="main_right">
	<div id="r_title">
		<div id="r_title_content">
			角色管理 &gt; 编辑角色【<?php echo $r_val['role_name'];?>】
		</div>
	</div>
	<div class="line_white"></div>
	<div id="r_menu">
		<ul>
			<li><a href="<?php echo base_url('manage/role');?>">返回列表</a></li>
		</ul>
	</div>
	<div id="r_list">
		<form action="<?php echo base_url('manage/role/edit?r_id=').$r_val['role_id'];?>" method="post" onsubmit="return na_check_form();">
		<table id="edit_r" width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-bottom:50px;">
		  <tr>
			<td style="width:10%; height:35px;text-align:center;">角色名称</td>
			<td width="90%" style="padding-left:10px;"><input type="text" size="25" name="role_name" id="role_name"class="inputs" value="<?php echo $r_val['role_name'];?>" /></td>
		  </tr>
		  <tr>
			<td width="10%" height="35" align="center" style="text-align:center;">角色权限</td>
			<td width="90%" id="check_box_in">
				<div class="xuan_edit">
					<a href="javascript:select_all();">全选</a>&nbsp;|&nbsp;
					<a href="javascript:select_versa();">反选</a>&nbsp;|&nbsp;
				    <a href="javascript:select_none();">全部取消</a>
				</div>
				<?php foreach($rolesOneArr as $rolesOneRows):?>
				<?php if($rolesOneRows['menu_pid'] == 0):?>	
				<div style="height:100px; height:100px;">
					<h4><?=$rolesOneRows['menu_name'];?></h4><br>
					<?php if(!empty($rolesSonArr[$rolesOneRows['menu_id']])):?>
						<?php foreach($rolesSonArr[$rolesOneRows['menu_id']] as $rolesSonRows):?>
							<div style="height:25px; height:25px;">
							<?=$rolesSonRows['menu_name']?>：
							<?php if(!empty($rolesSonRows['sonArr'])):?>
							<?php foreach($rolesSonRows['sonArr'] as $k=>$v):?>
								<input type="checkbox" name="<?=$v['menu_id'];?>" value="<?=$v['menu_id'];?>" />&nbsp;<?=$v['menu_name'];?>
							<?php endforeach;?>	
							</div>
							<?php endif;?>
						<?php endforeach;?>
					<?php endif;?>
				</div>
				<?php endif;?>
				<?php endforeach;?>
			</td>
		  </tr>
		  <tr>
			<td width="10%" height="35" align="center">&nbsp;</td>
			<td width="90%" style="padding-left:10px;"><input type="image" src="<?php echo base_url('publics/admin/');?>/images/edit_bg.jpg"/></td>
		  </tr>
		 </table>
		 </form>
		 <input type="hidden" value="<?php echo $r_val['role_popedom']?>" id="role_popedom" />
	</div>
</div>
</body>
</html>
<script>
function na_check_form()
{
	//检查角色名称
	var role_name=$('#role_name').val();
	if(role_name.length < 2)
	{
		alert('角色名称至少要为2个字符');
		$('#role_name').focus();
		return false;
	}
	// 检查权限的勾选情况
	var checkbox_num=$('#check_box_in :checkbox:checked').size();
	if(checkbox_num <=0)
	{
		alert('至少要选择一个权限');
		return false;
	}
	return true;
}
// 全选
function select_all()
{
	$('#check_box_in :checkbox').attr('checked',true);
	$('#check_box_in :checkbox').each(function(){
		//判断checkbox 的状态
		$('#check_box_in :checkbox').attr('checked',true);
		if(!$(this).is(':checked'))
		{
			$(this).click();
		}
	});
	
} 
// 取消全选
function select_none()
{
	$('#check_box_in :checkbox').each(function(){
		//判断checkbox 的状态
		if($(this).is(':checked'))
		{
			$(this).click();
		}
	});
}
function select_versa()
{
	//反选
	$('#check_box_in :checkbox').click();
}
$(function(){
	var role_p=$('#role_popedom').val();
	$('#check_box_in :checkbox').each(function(){
		var role_c=$(this).val();
		if(role_p.indexOf(role_c) != -1)
		{
			$(this).attr({'checked':true});
		}
	});
});

</script>